package com.example.lotterysystem.common.exception;

import com.example.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;
//@Data 生成自己的equals hashCode
@Data
@EqualsAndHashCode(callSuper = true)//为类添加equals和hashcode方法, callSuper = true表示进行比较时, 也会比较父类的属性, 避免错误
public class ControllerException extends RuntimeException{
    private Integer code;
    private String msg;

    //为了序列化
    public ControllerException(){

    }

    public ControllerException(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public ControllerException(ErrorCode errorCode){
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }
}
